<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <h1>这是3000端口下的文件</h1>
    <button class="btn">点击发送ajax到4000端口请求数据</button>
    <button class="btn2">点击发送ajax到3000端口</button>
    <button class="btn3">点击通过模块发送请求</button>

    <script>
        let btn = document.querySelector(".btn");
        btn.onclick = function() {
            let xhr = new XMLHttpRequest();
            xhr.open("get", "http://localhost:4000/test");
            xhr.onload = function() {
                console.log(xhr.responseText);
            };
            xhr.send();
        };
        let btn2 = document.querySelector(".btn2");
        btn2.onclick = function() {
            let xhr = new XMLHttpRequest();
            xhr.open("get", "/getdata");
            xhr.onload = function() {
                console.log(xhr.responseText);
            };
            xhr.send();
        };
        let btn3 = document.querySelector(".btn3");
        btn3.onclick = function() {
            let xhr = new XMLHttpRequest();
            xhr.open("get", "/api/getnew");
            xhr.onload = function() {
                console.log(xhr.responseText);
            };
            xhr.send();
        };
    </script>
</body>

</html>